<?php
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use App\Models\Relations\UserInfoTrait;
use App\Models\Relations\CommonTrait;
class BbsAnswer extends Model
{
    use SoftDeletes,UserInfoTrait,CommonTrait;
    
    protected $table="bbs_answer";
    
    
    protected $fillable = ['id','question_id','title','agree_count','against_count',
                        'user_id','comment_count','thanks_count','uninterested_count','category_id',
                        'has_attach','force_fold'];
    
    protected $dates = ['deleted_at'];

    /**
     * 根据回答来获取问题的标题
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function getQuestionByAnswer()
    {
        return $this->belongsTo('App\Models\BbsQuestion', 'id');
    }

    public function getAnswerComment()
    {
        return $this->hasMany('App\Models\BbsAnswerComment', 'answer_id','id');
    }  
    
    public function question()
    {
        return $this->belongsTo('App\Models\BbsQuestion');
    }
}
